Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(python)!: Update group_by iteration and partition_by to always return tuple keys #16793

Merged
merged 3 commits into from
Jun 6, 2024

Conversation

stinodego
Copy link
Member

@stinodego stinodego commented Jun 6, 2024

Ref #13525 , #13371

Changes

  • Update group_by iteration to always return tuple keys
  • Update partition_by(as_dict=True) to always return tuple keys

Example

Before

>>> df = pl.DataFrame({"a": [1, 1, 2], "b": [3, 4, 5]})
>>> df.partition_by("a", as_dict=True).keys()
dict_keys([1, 2])

After

>>> df.partition_by("a", as_dict=True).keys()
dict_keys([(1,), (2,)])

@github-actions github-actions bot added breaking Change that breaks backwards compatibility enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Jun 6, 2024
Copy link

codecov bot commented Jun 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.35%. Comparing base (f4549f1) to head (a7f46f2).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16793      +/-   ##
==========================================
+ Coverage   81.33%   81.35%   +0.02%     
==========================================
  Files        1424     1424              
  Lines      187172   187246      +74     
  Branches     2697     2691       -6     
==========================================
+ Hits       152235   152337     +102     
+ Misses      34441    34413      -28     
  Partials      496      496              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stinodego stinodego marked this pull request as ready for review June 6, 2024 19:56
@stinodego stinodego merged commit efac81c into main Jun 6, 2024
19 checks passed
@stinodego stinodego deleted the break-groupby-iter branch June 6, 2024 20:18
@c-peters c-peters added the accepted Ready for implementation label Jun 9, 2024
@stinodego stinodego removed the breaking Change that breaks backwards compatibility label Jun 12, 2024
@stinodego stinodego changed the title feat(python)!: Update group-by iteration to always return tuple keys feat(python)!: Update group_by iteration and partition_by to always return tuple keys Jun 12, 2024
@github-actions github-actions bot added the breaking Change that breaks backwards compatibility label Jun 12, 2024
@s-banach
Copy link
Contributor

The new annotation tuple[object, ...] has caused some minor annoyance.
In the past, I could annotate parts: dict[TypeOfMyKey, pl.DataFrame] = df.partition_by(key, as_dict=True).
Now the type checker will tell me tuple[object, ...] is incompatible with TypeOfMyKey.
Is there an advantage to object over Any in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants